package collection;

import java.util.ArrayList;
import java.util.Collection;

/** 集合间的操作*/
public class CollectionOperDemo {
    public static void main(String[] args) {
        Collection c1=new ArrayList();
        c1.add("java");
        c1.add("c++");
        c1.add(".int");
        System.out.println("c1为："+c1);//c1为：[java,c++,.int]
        Collection c2=new ArrayList();
        c2.add("ok");
        c2.add("pp");
        c2.add(".nh");
        System.out.println("c2为："+c2);//c2为：[ok,pp,.nh]

        c1.addAll(c2);
        System.out.println("c1为："+c1);//c1为：[java,c++,.int,ok,pp,.nh]
        System.out.println("c2为："+c2);//c2为：[ok,pp,.nh]

        Collection c3=new ArrayList();
        c3.add("java");
        c3.add(".int");
        c3.add("poe");
        System.out.println("c3为："+c3);//c3为：[java,.int,poe]
        boolean contains=c1.containsAll(c3);
        System.out.println("是否包含："+contains);//false不包含

        c1.removeAll(c3);
        System.out.println("c1为："+c1);//c1为：[C++,poe]
        System.out.println("c3为："+c3);//c3为：[java,.int,poe]
    }
}
